/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.admin.service;

import org.springblade.core.mp.base.BaseService;
import org.springblade.modules.admin.dto.NewWorkPlanSendDTO;
import org.springblade.modules.admin.entity.MaintainPlanContent;
import org.springblade.modules.admin.entity.MaintainPlanContentUser;
import org.springblade.modules.admin.entity.MaintainPlanUserDayCount;
import org.springblade.modules.admin.vo.MaintainPlanContentUserVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.admin.vo.plan.PlanMaintainUserVO;

import java.util.List;

/**
 * 维保任务关联人员中间表 服务类
 *
 * @author BladeX
 * @since 2021-05-10
 */
public interface IMaintainPlanContentUserService extends BaseService<MaintainPlanContentUser> {

	/**
	 * 自定义分页
	 *
	 * @param page
	 * @param maintainPlanContentUser
	 * @return
	 */
	IPage<MaintainPlanContentUserVO> selectMaintainPlanContentUserPage(IPage<MaintainPlanContentUserVO> page, MaintainPlanContentUserVO maintainPlanContentUser);

    List<String> selectLastFinishedPlanUserPhones(Long planId);

	/**
	 * 根据任务id查找维保员信息
	 */
	List<PlanMaintainUserVO> selectWorkUsers(Long planId);

	/**
	 * 批量分配
	 * @param list
	 * @return
	 */
    boolean addBatch(List<MaintainPlanContentUser> list);

	/**
	 * 更新用户的签到信息
	 * @param planId 任务id
	 * @param signType 1:签到,2：签退 对应SignEnum
	 * @param userId 用户id
	 * @param signStatus 用户签到状态
	 */
	void updatePlanUserSignInfo(Long planId, Integer signType, Long userId, Integer signStatus);

    List<MaintainPlanContentUser> listByPlanId(List<Long> planIds);

    List<MaintainPlanUserDayCount> listInPlanDate();

	List<MaintainPlanUserDayCount> listNotInPlanDate();

	List<MaintainPlanContentUser> listByWxPlanId(List<Long> planIds);

    List<MaintainPlanContent> selectPlanContentByUser(Long userId);

	/**
	 * 新事务工单批量 指派/转派
	 * @param newWorkPlanSendDTO 工单id、指派用户id 集合
	 * @return 是否成功
	 */
    boolean send(NewWorkPlanSendDTO newWorkPlanSendDTO);

	/**
	 * 所有 执行人列表，包括已删除的，取最小值
	 * @return 执行人列表
	 */
    List<MaintainPlanContentUser> listAllContentUsersByPlanId(Long currentPlanId);

	List<MaintainPlanContentUser> listAllByPlanIds(List<Long> planIds);
}
